﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace NurseStation.Convert
{
    /// <summary>
    /// 隐藏MutiConvert
    /// </summary>
    public class Int2VisibilityConvert : IValueConverter
    {
        /// <summary>
        /// 指定参数匹配字符串转显隐方法  2022-03-28
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string parm = "show";//1显示，否则隐藏
            if (parameter != null)
                parm = parameter.ToString();
            Visibility visbility = Visibility.Collapsed;
            try
            {
                if (parm == "hidden")
                {
                    if (value != null && value.ToString() == "1")
                    {
                        visbility = Visibility.Collapsed;
                    }
                    else
                    {
                        visbility = Visibility.Visible;
                    }
                }
                else 
                {
                    if (value != null && value.ToString() == "1")
                    {
                        visbility = Visibility.Visible;
                    }
                    else
                    {
                        visbility = Visibility.Collapsed;
                    }
                }
            }
            catch
            {
            }
            return visbility;
        }

        /// <summary>
        /// 接口实现  
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return string.Empty;
        }
    }
}
